package Chinese.Education.Identify.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;
import java.util.HashMap;
import java.util.Map;

@RestController
public class SessionTestController {

    @RequestMapping("/session/test")
    public Map<String, Object> testSession(HttpServletRequest request) {
        Map<String, Object> result = new HashMap<>();
        HttpSession session = request.getSession();
        Object user = session.getAttribute("user");

        result.put("sessionId", session.getId());
        result.put("userInSession", user);
        result.put("hasUser", user != null);

        System.out.println("Session test - Session ID: " + session.getId() + ", User: " + user);
        return result;
    }
}
